package com.dc.designPattern._11_proxy.extend.extend2;

/**
 * Description: 强制代理_代理者_游戏代理
 * @author: gdc
 * @date: 2021/6/24
 * @version 1.0
 */
public class GamePlayerProxy implements IGamePlayer {

    /**
     * 目标对象，通过接口完成聚合
     */
    private IGamePlayer gamePlayer;

    /**
     * 代理对象的构造函数
     * @param gamePlayer          目标对象
     */
    public GamePlayerProxy(IGamePlayer gamePlayer) {
        this.gamePlayer = gamePlayer;
    }

    @Override
    public void login(String user, String pwd) {
        this.gamePlayer.login(user, pwd);
    }

    @Override
    public void killBoss() {
        this.gamePlayer.killBoss();
    }

    @Override
    public void upgrade() {
        this.gamePlayer.upgrade();
    }

    /**
     * 当前代理对象，没有再代理对象，因此返回自己，否则返回其代理对象
     */
    @Override
    public IGamePlayer getProxy() {
        return this;
    }
}
